<template>
	<view class="module-list">
		<public-list ref="publicListShow" :params="queryParam" :listRecord="model" nativeTo="/application/moduleShow"
			nativeToEdit="/application/moduleAddEdit" :isTreeView="isTreeView"></public-list>
	</view>
</template>
<script setup>
	import PublicList from "./publicList.vue";
	import {
		ref
	} from 'vue'
	import {
		onPullDownRefresh,
		onReachBottom,
		onShow,
		onLoad
	} from '@dcloudio/uni-app'

	const describe = '模块列表'
	const model = ref({})
	const queryParam = ref({
		moduleCode: ""
	})
	const isDoRefresh = ref({})
	const isReadShow = ref(false)
	const isTreeView = ref(false)
	onLoad((options) => {
		console.log('options', options);
		isTreeView.value = options.isTreeView == 'true' ? true : false
		model.value = JSON.parse(options.record);
		console.log('model', model.value);
		queryParam.value.moduleCode = model.value.code;
		queryParam.value.formCode = model.value.formCode;
		// 操作列模块型按钮带入的模块 ID
		queryParam.value.moduleId = model.value.moduleId;
		queryParam.value.treeNodeCode = model.value.treeNodeCode;
		// 点赞的主模块
		queryParam.value.mainModuleCode = model.value.mainModuleCode;
		search();

		// 初始化updatePage事件
		uni.$off('updatePage')
		uni.$on('updatePage', (data) => {
			search()
		})
	})

	onShow(() => {
		if (!isReadShow.value) {
			isReadShow.value = true;
		} else {
			// 防止每次进入界面时刷新
			// 20250101 因为后端h5页面添加返回后需要刷新，故去掉此处的注释
			search();
		}
		// if (isDoRefresh.value == true) {
		// 	currPage.isDoRefresh.value = false;
		// 	search();
		// }
	})
	// onPullDownRefresh(() => {
	// 	// #ifdef MP-WEIXIN
	// 	search();
	// 	wx.stopPullDownRefresh();
	// 	// #endif

	// 	// #ifdef APP-ANDROID || H5 || APP-PLUS
	// 	console.log('APP-ANDROID')
	// 	uni.startPullDownRefresh();
	// 	search();
	// 	uni.stopPullDownRefresh();
	// 	// #endif

	// 	// #ifdef APP-IOS || APP-HARMONY
	// 	search();
	// 	setTimeout(() => {
	// 		uni.stopPullDownRefresh();
	// 		uni.pageScrollTo({
	// 			scrollTop: 0,
	// 			duration: 300
	// 		}, 20);
	// 	})
	// 	// #endif
	// })

	const publicListShow = ref(null)

	// onReachBottom(() => {
	// 	publicListShow.value.getOnReachBottom();
	// })
	const search = () => {
		setTimeout(() => {
			publicListShow.value.search();
		}, 200);
	}
</script>
<style>
	uni-page-body{
		overflow: unset;
	}
</style>
<style lang="scss" scoped>
	.module-list {
		height: 100%;
	}
</style>